﻿namespace PMS.Client.FrmJobTitle
{
    using AdvancedDataGridView;
    using PMS.BLL;
    using PMS.Model;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Linq;
    using System.Windows.Forms;

    public class FrmCount : Form
    {
        private IContainer components = null;
        private DataGridViewTextBoxColumn Count_Allow;
        private DataGridViewTextBoxColumn Count_Reality;
        private Label lbTitle;
        private TreeGridColumn TitleName;
        private TreeGridView treeGridView1;

        public FrmCount(int OrganID)
        {
            this.InitializeComponent();
            List<UserTypeCount> countList = new UserTypeBLL().GetCountList(OrganID);
            List<OrganJobPosistion_Count> list2 = new OrganJobPosistionBLL().GetCountList(OrganID);
            TreeGridNode node = this.treeGridView1.Nodes.Add(new object[] { "职数总计", 0, 0 });
            TreeGridNode node2 = node.Nodes.Add(new object[] { "领导职数小计", (from f in countList
                where f.IsLeader == 1
                select f).Sum<UserTypeCount>((Func<UserTypeCount, int>) (f => f.Count_Allow)), (from f in countList
                where f.IsLeader == 1
                select f).Sum<UserTypeCount>((Func<UserTypeCount, int>) (f => f.Count_Reality)) });
            TreeGridNode node3 = node.Nodes.Add(new object[] { "非领导职数小计", (from f in countList
                where f.IsLeader == 0
                select f).Sum<UserTypeCount>((Func<UserTypeCount, int>) (f => f.Count_Allow)), (from f in countList
                where f.IsLeader == 0
                select f).Sum<UserTypeCount>((Func<UserTypeCount, int>) (f => f.Count_Reality)) });
            TreeGridNode node4 = node.Nodes.Add(new object[] { "核定领导职数小计", (from f in list2
                where f.IsLeader == 1
                select f).Sum<OrganJobPosistion_Count>((Func<OrganJobPosistion_Count, int>) (f => f.Count_Allow)), (from f in list2
                where f.IsLeader == 1
                select f).Sum<OrganJobPosistion_Count>((Func<OrganJobPosistion_Count, int>) (f => f.Count_Reality)) });
            TreeGridNode node5 = node.Nodes.Add(new object[] { "核定非领导职数小计", (from f in list2
                where f.IsLeader == 0
                select f).Sum<OrganJobPosistion_Count>((Func<OrganJobPosistion_Count, int>) (f => f.Count_Allow)), (from f in list2
                where f.IsLeader == 0
                select f).Sum<OrganJobPosistion_Count>((Func<OrganJobPosistion_Count, int>) (f => f.Count_Reality)) });
            TreeGridNode node6 = node.Nodes.Add(new object[] { "领导职数高配小计", 0, 0 });
            foreach (UserTypeCount count in countList)
            {
                if (count.IsLeader == 1)
                {
                    node2.Nodes.Add(new object[] { count.TypeName, count.Count_Allow, count.Count_Reality });
                }
                else
                {
                    node3.Nodes.Add(new object[] { count.TypeName, count.Count_Allow, count.Count_Reality });
                }
            }
            foreach (OrganJobPosistion_Count count2 in list2)
            {
                if (count2.IsLeader == 1)
                {
                    node4.Nodes.Add(new object[] { count2.PositionName, count2.Count_Allow, count2.Count_Reality });
                }
                else
                {
                    node5.Nodes.Add(new object[] { count2.PositionName, count2.Count_Allow, count2.Count_Reality });
                }
            }
            Font font = new Font(this.treeGridView1.DefaultCellStyle.Font, FontStyle.Bold);
            DataGridViewCellStyle style2 = new DataGridViewCellStyle {
                Font = font,
                ForeColor = Color.White,
                BackColor = SystemColors.Highlight
            };
            DataGridViewCellStyle style = style2;
            node.Expand();
            node.DefaultCellStyle = node2.DefaultCellStyle = node3.DefaultCellStyle = node4.DefaultCellStyle = node5.DefaultCellStyle = node6.DefaultCellStyle = style;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            DataGridViewCellStyle style3 = new DataGridViewCellStyle();
            DataGridViewCellStyle style4 = new DataGridViewCellStyle();
            this.lbTitle = new Label();
            this.treeGridView1 = new TreeGridView();
            this.TitleName = new TreeGridColumn();
            this.Count_Allow = new DataGridViewTextBoxColumn();
            this.Count_Reality = new DataGridViewTextBoxColumn();
            ((ISupportInitialize) this.treeGridView1).BeginInit();
            base.SuspendLayout();
            this.lbTitle.BackColor = Color.Gold;
            this.lbTitle.Dock = DockStyle.Top;
            this.lbTitle.Font = new Font("宋体", 14.25f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbTitle.ForeColor = Color.Black;
            this.lbTitle.Location = new Point(0, 0);
            this.lbTitle.Name = "lbTitle";
            this.lbTitle.Size = new Size(0x2e8, 0x1f);
            this.lbTitle.TabIndex = 11;
            this.lbTitle.Text = "职数情况";
            this.lbTitle.TextAlign = ContentAlignment.MiddleCenter;
            this.treeGridView1.AllowUserToAddRows = false;
            this.treeGridView1.AllowUserToDeleteRows = false;
            this.treeGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this.treeGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            this.treeGridView1.BackgroundColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            this.treeGridView1.BorderStyle = BorderStyle.Fixed3D;
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = SystemColors.Control;
            style.Font = new Font("宋体", 9f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            style.ForeColor = SystemColors.WindowText;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = SystemColors.HighlightText;
            style.WrapMode = DataGridViewTriState.True;
            this.treeGridView1.ColumnHeadersDefaultCellStyle = style;
            this.treeGridView1.Columns.AddRange(new DataGridViewColumn[] { this.TitleName, this.Count_Allow, this.Count_Reality });
            style2.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style2.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            style2.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style2.ForeColor = SystemColors.ControlText;
            style2.SelectionBackColor = SystemColors.Highlight;
            style2.SelectionForeColor = SystemColors.HighlightText;
            style2.WrapMode = DataGridViewTriState.False;
            this.treeGridView1.DefaultCellStyle = style2;
            this.treeGridView1.Dock = DockStyle.Left;
            this.treeGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
            this.treeGridView1.EnableHeadersVisualStyles = false;
            this.treeGridView1.ImageList = null;
            this.treeGridView1.Location = new Point(0, 0x1f);
            this.treeGridView1.MultiSelect = false;
            this.treeGridView1.Name = "treeGridView1";
            this.treeGridView1.RowHeadersVisible = false;
            this.treeGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.treeGridView1.Size = new Size(0x221, 0x1a2);
            this.treeGridView1.TabIndex = 12;
            style3.Font = new Font("宋体", 9f);
            this.TitleName.DefaultCellStyle = style3;
            this.TitleName.DefaultNodeImage = null;
            this.TitleName.FillWeight = 60f;
            this.TitleName.HeaderText = "职位名称";
            this.TitleName.Name = "TitleName";
            this.TitleName.Resizable = DataGridViewTriState.True;
            this.TitleName.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.Count_Allow.FillWeight = 20f;
            this.Count_Allow.HeaderText = "核定职数";
            this.Count_Allow.Name = "Count_Allow";
            this.Count_Allow.SortMode = DataGridViewColumnSortMode.NotSortable;
            style4.Font = new Font("宋体", 9f);
            this.Count_Reality.DefaultCellStyle = style4;
            this.Count_Reality.FillWeight = 20f;
            this.Count_Reality.HeaderText = "实配职数";
            this.Count_Reality.Name = "Count_Reality";
            this.Count_Reality.Resizable = DataGridViewTriState.True;
            this.Count_Reality.SortMode = DataGridViewColumnSortMode.NotSortable;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            base.ClientSize = new Size(0x2e8, 0x1c1);
            base.Controls.Add(this.treeGridView1);
            base.Controls.Add(this.lbTitle);
            base.Name = "FrmCount";
            this.Text = "FrmCount";
            ((ISupportInitialize) this.treeGridView1).EndInit();
            base.ResumeLayout(false);
        }
    }
}

